class Solution
{
public:
    bool canReach(string s, int minJump, int maxJump)
    {
        int n = s.size();
        if (s[n - 1] == '1')
        {
            return false;
        }
        s[0] = '2';
        int maxSearched = 0;
        for (int i = 0; i < n; ++i)
        {
            if (s[i] == '2')
            {
                for (int j = max(i + minJump, maxSearched + 1); j <= i + maxJump && j < n; ++j)
                {
                    if (s[j] == '0')
                    {
                        s[j] = '2';
                    }
                }
                maxSearched = min(i + maxJump, n - 1);
            }
        }
        return s[n - 1] == '2';
    }
};